<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<div id="alertDialog" title="提示" style="display:none;">
	<div id="alertMessage" style="padding:10px;height:160px;"></div>
</div>

<script type="text/javascript">
(function(){
	if (typeof window.oalert == 'function')
		return;
	window.oalert = window.alert;
	var $$alert = window.oalert;
	window.alert = function (msg, title, callback) {
//		$$alert(arguments[0]);
		if (arguments.length < 2) {
			$$alert(msg);
			return;
		}
		var dialog = $("#alertDialog:first");
		var m = $("#alertMessage", dialog);
		if (dialog.css('display') == 'none') {
			var h = m.html();
			m.html(msg + "<br/>" + h);
		} else {
			if (dialog.dialog("isOpen")) {
				var h = m.html();
				m.html(msg + "<br/>" + h);
			} else {
				m.html(msg);
			}
		}
		dialog.dialog({
			height: 260,
			width: 400,
			modal: true,
			autoOpen: true,
			title: (typeof title == 'string' && title.length > 0) ? title : "提示",
			buttons: {
				'确定': function() {
					if (typeof callback == 'function'){
						if (callback() === false)
							return;;
					}
					$(this).dialog('close');
				}
			}
		});
	};
	window.$alert = function(msg) {
		window.alert(msg, null);
	};
	window.closeAlert = function() {
		$("#alertDialog").dialog('close');
	};
})();

</script>